﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Gameplay.CharacterFramework
{

    [CreateAssetMenu(fileName = "NewNormalAttackCombo", menuName = "Skills/NormalAttackCombo")]
    public class NormalAttackCombo : Skill
    {
        public float IntervalTime;

        public List<AudioClip> AudioClips;

        public List<AnimationClip> animationClips;

        private int _comboCount = 0;
        private float lastTime = 0;//上一次输入时间
        private bool _active = false;

        public override void Use(Role user)
        {
            base.Use(user);
            _animationComponent.PlayCustomSkill(animationClips[_comboCount]);
            lastTime = Time.time;
            _comboCount++;
            _active = true;
            
        }
   
        public override void Update()
        {
            if (_active)
            {
                if (Time.time - lastTime > IntervalTime)
                {
                    _comboCount = 0;
                    _active = false;
                }
            }
        }
        public override void Trigger()
        {
           
            AudioManager.Instance.PlaySound(AudioClips[_comboCount-1]);
            _particleManager.PlaySwordTrail(Config.effectVFX, _comboCount-1);

            if (_comboCount > 2)
            {
                _comboCount = 0;
            }
            CurrentWeapon.SetActive(true);
        }

        public override void Finish()
        {
            CurrentWeapon.SetActive(false);
        }

        

        
    }
}
